<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <ul>
        <li><a href="#/home">home</a></li>
        <li><a href="#/about">about</a></li>
    </ul>

    <div id="routerView"></div>

    <script>

        var routerView = document.getElementById('routerView')

        // 页面加载完毕时,调用
        window.addEventListener('DOMContentLoaded', onHashchange)

        // 监听url的变化
        window.addEventListener('hashchange', onHashchange)

        function onHashchange() {
            switch (location.hash) {
                case '#/home':
                routerView.innerHTML = 'Home page'
                return
                case '#/about':
                routerView.innerHTML = 'About page'
                return
                default:
                return
            }

            console.log(location.hash);
        }
    </script>
</body>
</html>